<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class ContactusValidate extends CoreValidate {
	
	//constructor
	function ContactusValidate() {
		
	}
	
	//methods
	function check($data_array) {
		//name
		if( $this->_str_eq($data_array['field_name'], 0) ) {
			$this->_add('field_name', 'The Name is Null');
		} elseif( $this->_str_lt($data_array['field_name'], 5) ) {
			$this->_add('field_name', 'The Name is less than 5 characters');
		} elseif( $this->_str_gt($data_array['field_name'], 20) ) {
			$this->_add('field_name', 'The Name is more than 20 characters');
		}
		//telephone
		if( $this->_str_eq($data_array['field_telephone'], 0) ) {
			$this->_add('field_telephone', 'The Telephone is Null');
		} elseif( $this->_str_lt($data_array['field_telephone'], 5) ) {
			$this->_add('field_telephone', 'The Telephone is less than 5 characters');
		} elseif( $this->_str_gt($data_array['field_telephone'], 20) ) {
			$this->_add('field_telephone', 'The Telephone is more than 20 characters');
		}
		//email
		if( $this->_str_eq($data_array['field_email_address'], 0) ) {
			$this->_add('field_email_address', 'The Email is Null');
		} elseif( $this->_valid_email($data_array['field_email_address']) ) {
			$this->_add('field_email_address', 'The Email is invalid');
		}
		//message
		if( $this->_str_eq($data_array['field_message'], 0) ) {
			$this->_add('field_message', 'The Message is Null');
		} elseif( $this->_str_lt($data_array['field_message'], 5) ) {
			$this->_add('field_message', 'The Message is less than 5 characters');
		} elseif( $this->_str_gt($data_array['field_message'], 2000) ) {
			$this->_add('field_message', 'The Message is more than 20 characters');
		}
	}
}
//
?>